home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / network / ka9q / ka9q_src.arc / IP.H < prev    next >
C/C++ Source or Header  |  1988-07-28  |  3KB  |  99 lines

  1. #define    NROUTE    5    /* Number of hash chains in routing table */
  2.  
  3. extern int32 ip_addr;    /* Our IP address for ICMP and source routing */
  4.  
  5. extern char ip_ttl;    /* Default time-to-live for IP datagrams */
  6.  
  7. #define    IPVERSION    4
  8. /* IP header, INTERNAL representation */
  9. struct ip {
  10.     char version;        /* IP version number */
  11.     char tos;        /* Type of service */
  12.     int16 length;        /* Total length */
  13.     int16 id;        /* Identification */
  14.     int16 fl_offs;        /* Flags + fragment offset */
  15.  
  16. #define    F_OFFSET    0x1fff    /* Offset field */
  17. #define    DF    0x4000        /* Don't fragment flag */
  18. #define    MF    0x2000        /* More Fragments flag */    
  19.  
  20.     char ttl;        /* Time to live */
  21.     char protocol;        /* Protocol */
  22.     int32 source;        /* Source address */
  23.     int32 dest;        /* Destination address */
  24.     char options[44];    /* Options field */
  25.     int16 optlen;        /* Length of options field, bytes */
  26. };
  27. #define    NULLIP    (struct ip *)0
  28. #define    IPLEN    20    /* Length of standard IP header */
  29.  
  30. /* Fields in option type byte */
  31. #define    OPT_COPIED    0x80    /* Copied-on-fragmentation flag */
  32. #define    OPT_CLASS    0x60    /* Option class */
  33. #define    OPT_NUMBER    0x1f    /* Option number */
  34.  
  35. /* IP option numbers */
  36. #define    IP_EOL        0    /* End of options list */
  37. #define    IP_NOOP        1    /* No Operation */
  38. #define    IP_SECURITY    2    /* Security parameters */
  39. #define    IP_LSROUTE    3    /* Loose Source Routing */
  40. #define    IP_TIMESTAMP    4    /* Internet Timestamp */
  41. #define    IP_RROUTE    7    /* Record Route */
  42. #define    IP_STREAMID    8    /* Stream ID */
  43. #define    IP_SSROUTE    9    /* Strict Source Routing */
  44.  
  45. /* Timestamp option flags */
  46. #define    TS_ONLY        0    /* Time stamps only */
  47. #define    TS_ADDRESS    1    /* Addresses + Time stamps */
  48. #define    TS_PRESPEC    3    /* Prespecified addresses only */
  49.  
  50. /* IP routing table entry */
  51. struct route {
  52.     struct route *prev;    /* Linked list pointers */
  53.     struct route *next;
  54.     int32 target;        /* Target IP address */
  55.     int32 gateway;        /* IP address of local gateway for this target */
  56.     int metric;        /* Hop count, whatever */
  57.     struct interface *interface;    /* Device interface structure */
  58. };
  59. #define    NULLROUTE    (struct route *)0
  60. extern struct route *routes[32][NROUTE];    /* Routing table */
  61. extern struct route r_default;            /* Default route entry */
  62.  
  63. /* Reassembly descriptor */
  64. struct reasm {
  65.     struct reasm *next;    /* Linked list pointers */
  66.     struct reasm *prev;
  67.     int32 source;        /* These four fields uniquely describe a datagram */
  68.     int32 dest;
  69.     int16 id;
  70.     char protocol;
  71.     int16 length;        /* Entire datagram length, if known */
  72.     struct timer timer;    /* Reassembly timeout timer */
  73.     struct frag *fraglist;    /* Head of data fragment chain */
  74. };
  75. #define    NULLREASM    (struct reasm *)0
  76.  
  77. /* Fragment descriptor in a reassembly list */
  78. struct frag {
  79.     struct frag *prev;    /* Previous fragment on list */
  80.     struct frag *next;    /* Next fragment */
  81.     struct mbuf *buf;    /* Actual fragment data */
  82.     int16 offset;        /* Starting offset of fragment */
  83.     int16 last;        /* Ending offset of fragment */
  84. };
  85. #define    NULLFRAG    (struct frag *)0
  86.  
  87. extern struct reasm *reasmq;    /* The list of reassembly descriptors */
  88.  
  89. /* IP error logging counters */
  90. struct ip_stats {
  91.     long total;        /* Total packets received */
  92.     unsigned runt;        /* Smaller than minimum size */
  93.     unsigned length;    /* IP header length field too small */
  94.     unsigned version;    /* Wrong IP version */
  95.     unsigned checksum;    /* IP header checksum errors */
  96.     unsigned badproto;    /* Unsupported protocol */
  97. };
  98. extern struct ip_stats ip_stats;
  99.